import {
  createApp
} from 'vue'
import router from './router'
import store from './store'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import request from './utils/request'
import storage from './utils/storage'
import api from './api'
import queryForm from '../packages/QueryForm/index'

const app = createApp(App)

app.directive('has', {
  beforeMount: (el, binding) => {
    // console.log(el, binding)
    // 获取按钮权限
    let actionList = storage.getItem("actionList")
    let value = binding.value;
    // 盘点列表中是否有对应按钮权限标识
    let hasPermission = actionList.includes(value)
    if (!hasPermission) {
      el.style = 'display:none';
      setTimeout(() => {
        el.parentNode.removeChild(el);
      }, 0);
    }
  }
})

app.config.globalProperties.$request = request
app.config.globalProperties.$api = api
app.config.globalProperties.$storage = storage
app.use(router)
app.use(store)
app.use(ElementPlus, {
  size: 'small'
})
app.use(queryForm)

console.log('环境变量：',
  import.meta.env)
app.mount('#app')